﻿using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Printing;
using System.Reflection;
using System.Windows.Forms;
using System.Xml;
using TextEditor;
using Bifrost;
using TextEditor.TextDocument.Document;
using System.Text;

namespace ZYCommon
{
    public class PrintPageCollection
    {
        private int intBottomMargin = 120;
        private int intHeadHeight = 0;
        private int intLeftMargin = 150;
        //private int intLeftMargin = 500;
        private int intMinPageHeight = 30;
        private int intPaperHeight = 1123;
        private int intPaperWidth = 794;
        private int intRightMargin = 96;
        private int intTailHeight = 0;
        private int intTop = 0;
        private int intTopMargin = 120;
        private ArrayList myItems = new ArrayList();
        private System.Drawing.Printing.PageSettings myPageSettings = new System.Drawing.Printing.PageSettings();
        public const float PVMM = 37.8f;
        protected int intFooterHeight = 0;
        //protected int intHeadHeight = 0;
        protected int intDocumentHeight = 0;
        public string paperSizeName = "A4";
        private int titleMarginTop = 0;
        public ZYAttributeCollection Attributes = new ZYAttributeCollection();

        private bool enablePageHeader = false;

        public bool EnablePageHeader
        {
            get { return enablePageHeader; }
            set
            {
                enablePageHeader = value;

                this.Attributes.SetValue("enableheader", value);
            }
        }
        private bool enablePageFooter = false;

        public bool EnablePageFooter
        {
            get { return enablePageFooter; }
            set
            {
                enablePageFooter = value;
                this.Attributes.SetValue("enablefooter", value);
            }
        }

        private bool landscape = false;

        public bool Landscape
        {
            get { return landscape; }
            set
            {
                landscape = value;
                if (value)
                {
                    this.intPaperWidth = height;
                    this.intPaperHeight = width;
                }
                else
                {
                    this.intPaperWidth = width;
                    this.intPaperHeight = height;
                }
                this.Attributes.SetValue("landscape", value);
            }
        }

        internal static string GetXMLName()
        {
            return "pagesetting";
        }

        public PrintPageCollection()
        {
            //if (PrinterSettings.InstalledPrinters.Count == 0)
            //{
            //    this.myPageSettings.PaperSize = new PaperSize("Custom", 0x31a, 0x463);
            //}
            this.UpdatePageSettings();
        }

        public bool ToXML(XmlElement myElement)
        {
            if (myElement != null)
            {
                this.Attributes.ToXML(myElement);
                return true;
            }
            return false;
        }

        public bool FromXML(XmlElement myElement)
        {
            if (myElement != null)
            {
                this.Attributes.FromXML(myElement);
                if (this.Attributes["paperkind"] != null)
                    this.paperSizeName = this.Attributes.GetString("paperkind");

                if (this.Attributes["paperwidth"] != null)
                {
                    this.PaperWidth = this.Attributes.GetInt32("paperwidth");
                }
                else
                {
                    this.PaperWidth = 827;
                }

                if (this.Attributes["paperheight"] != null)
                {
                    this.PaperHeight = this.Attributes.GetInt32("paperheight");
                }
                else
                {
                    this.PaperHeight = 1169;
                }

                if (this.Attributes["leftmargin"] != null)
                    this.intLeftMargin = this.Attributes.GetInt32("leftmargin");

                if (this.Attributes["rightmargin"] != null)
                    this.intRightMargin = this.Attributes.GetInt32("rightmargin");

                if (this.Attributes["topmargin"] != null)
                    this.intTopMargin = this.Attributes.GetInt32("topmargin");

                if (this.Attributes["bottommargin"] != null)
                    this.intBottomMargin = this.Attributes.GetInt32("bottommargin");

                if (this.Attributes["enableheader"] != null)
                    this.enablePageHeader = this.Attributes.GetBool("enableheader");

                if (this.Attributes["enablefooter"] != null)
                    this.enablePageFooter = this.Attributes.GetBool("enablefooter");
                if (this.Attributes["landscape"] != null)
                    this.Landscape = this.Attributes.GetBool("landscape");
                else
                    Landscape = false;
            }
            return true;
        }

        public string PaperKindName
        {
            set
            {
                paperSizeName = value;
                this.Attributes.SetValue("paperkind", value);
            }
            get { return paperSizeName; }
        }

        private int width = 0;
        private int height = 0;

        public int PaperWidth
        {
            get
            {
                return this.intPaperWidth;
            }
            set
            {
                width = value;
                this.intPaperWidth = value;
                this.Attributes.SetValue("paperwidth", value);
            }
        }

        public int PaperHeight
        {
            get
            {
                return this.intPaperHeight;
            }
            set
            {
                height = value;
                this.intPaperHeight = value;
                this.Attributes.SetValue("paperheight", value);
            }
        }

        public int LeftMargin
        {
            get
            {
                return this.intLeftMargin;
            }
            set
            {
                this.intLeftMargin = value;
                this.Attributes.SetValue("leftmargin", value);
            }
        }

        public int RightMargin
        {
            get
            {
                return this.intRightMargin;
            }
            set
            {
                this.intRightMargin = value;
                this.Attributes.SetValue("rightmargin", value);
            }
        }

        public int TopMargin
        {
            get
            {
                return this.intTopMargin;
            }
            set
            {
                this.intTopMargin = value;
                this.Attributes.SetValue("topmargin", value);
            }
        }


        public int BottomMargin
        {
            get
            {
                return this.intBottomMargin;
            }
            set
            {
                this.intBottomMargin = value;
                this.Attributes.SetValue("bottommargin", value);
            }
        }

        private string PageStyleStr()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("paperkind:");
            builder.Append(this.paperSizeName);
            builder.Append(";");
            builder.Append("paperwidth:");
            builder.Append(this.PaperWidth);
            builder.Append(";");
            builder.Append("paperheight:");
            builder.Append(this.PaperHeight);
            builder.Append(";");
            builder.Append("leftmargin:");
            builder.Append(this.LeftMargin);
            builder.Append(";");
            builder.Append("rightmargin:");
            builder.Append(this.RightMargin);
            builder.Append(";");
            builder.Append("topmargin:");
            builder.Append(this.TopMargin);
            builder.Append(";");
            builder.Append("bottommargin:");
            builder.Append(this.BottomMargin);
            return string.Empty;
        }

        public int TitleMarginTop
        {
            get
            {
                return titleMarginTop;
            }
            set
            {
                titleMarginTop = value;

            }
        }

        public void AddPage(PrintPage myPage)
        {
            if (!this.myItems.Contains(myPage))
            {
                this.myItems.Add(myPage);
            }
        }

        public void Clear()
        {
            this.myItems.Clear();
        }

        public bool ConfigPringPageSettings()
        {
            //打印设置
            using (PrintPageSettings settings = new PrintPageSettings())
            {
                settings.PageSettings = this.PageSettings;
                if (settings.ShowDialog() == DialogResult.OK)
                {
                    this.PageSettings = settings.PageSettings;
                    this.UpdatePageSettings();
                    return true;
                }
            }
            return false;
        }
        Font headNameFont = null;
        Font headHospitalTittleFont = null;
        Font bottomPageCurrent = null;
        Font headNameFont2 = null;
        Image LogoImg = null;
        public void DrawPageFrame(int x, int y, Graphics myGraph, bool DrawMargin, Color BackColor, int count, ZYTextDocument doc)
        {
            Rectangle rect = new Rectangle(x, y, this.intPaperWidth, this.intPaperHeight);
            if (DrawMargin)
            {
                using (SolidBrush brush = new SolidBrush(Color.White))
                {
                    myGraph.FillRectangle(brush, rect);
                }
                using (Pen blackPen = new Pen(Color.Black))
                {
                    myGraph.DrawRectangle(blackPen, rect);//纸张边框颜色
                }
            }
            Rectangle rectContent = new Rectangle(x + this.intLeftMargin, y + this.intTopMargin, this.StandardWidth, this.StandardHeight);
            PrintPage currentPage = ((PrintPage)this.myItems[count - 1]);
            if (doc.isDrawHeader())
            {
                if (!this.enablePageHeader)
                    doc.OnDrawHeader(myGraph, rectContent, count + doc.PageStartIndex, currentPage.PageHeadInfo);
            }
            else
            {
                if (!this.enablePageHeader)
                {
                    if (headNameFont == null)
                        headNameFont = doc.View._CreateFont("宋体", 12f, false, false, false);
                    if (headHospitalTittleFont == null)
                        headHospitalTittleFont = doc.View._CreateFont("黑体", 16, false, false, false);
                    if (headNameFont2 == null)
                        headNameFont2 = doc.View._CreateFont("宋体", 15f, false, false, false);
                    int maringLand = 0;

                    if (this.Landscape)
                    {
                        maringLand = Math.Abs(this.PaperWidth - this.PaperHeight) / 5;
                    }
                    myGraph.DrawLine(Pens.Black, rectContent.Left, rectContent.Top - 5, rectContent.Left + rectContent.Width, rectContent.Top - 5);
                    myGraph.DrawString(App.HospitalTittle, headHospitalTittleFont, Brushes.Black, new Rectangle(rectContent.Left, rectContent.Top - (this.TopMargin - this.titleMarginTop - 15), rectContent.Width, 25), doc.titleStringFormat);
                    myGraph.DrawString(doc.Us.TextName, headNameFont2, Brushes.Black, new Rectangle(rectContent.Left, rectContent.Top - (this.TopMargin - this.titleMarginTop - 40), rectContent.Width, 34), doc.titleStringFormat);
                    if (doc.HaveSuperiorSignature == "N" && doc.TextSuperiorSignature == "Y")
                    {
                        Watermark(rect.Left, rect.Top, myGraph);
                    }
                    if (doc.PageHeader != null)
                    {
                        ArrayList list = new ArrayList();
                        int maxWdith = 0;
                        string patient_name = "姓名:" + doc.PageHeader["姓名"];
                        int pWidth = GetTextWidth(myGraph, patient_name, headNameFont);
                        list.Add(new PageHeaderNode(patient_name, pWidth));
                        maxWdith += pWidth;

                        string bed_no = "床号:" + (currentPage.Bed_no != "" ? currentPage.Bed_no : doc.PageHeader["床号"]);
                        pWidth = GetTextWidth(myGraph, bed_no, headNameFont);
                        list.Add(new PageHeaderNode(bed_no, pWidth));
                        maxWdith += pWidth;

                        string section_name = "科别:" + (currentPage.Section_name != "" ? currentPage.Section_name : doc.PageHeader["科别"]);
                        pWidth = GetTextWidth(myGraph, section_name, headNameFont);
                        list.Add(new PageHeaderNode(section_name, pWidth));
                        maxWdith += pWidth;

                        string area_name = "病区:" + (currentPage.Sick_area != "" ? currentPage.Sick_area : doc.PageHeader["病区"]);
                        pWidth = GetTextWidth(myGraph, area_name, headNameFont);
                        list.Add(new PageHeaderNode(area_name, pWidth));
                        maxWdith += pWidth;


                        string p_id = "住院号:" + doc.PageHeader["住院号"];
                        pWidth = GetTextWidth(myGraph, p_id, headNameFont);
                        list.Add(new PageHeaderNode(p_id, pWidth));
                        maxWdith += pWidth;

                        int MarginWidth = (rectContent.Width - maxWdith) / (list.Count - 1);
                        int realWidth = 0;
                        foreach (PageHeaderNode node in list)
                        {
                            myGraph.DrawString(node.HeaderStr, headNameFont, Brushes.Black, rectContent.Left + realWidth, rectContent.Top - 26, StringFormat.GenericTypographic);
                            realWidth += node.Width + MarginWidth;
                        }
                    }
                }

                if (!this.enablePageFooter)
                {
                    if (bottomPageCurrent == null)
                        bottomPageCurrent = doc.View._CreateFont("宋体", 10.5f, false, false, false);
                    myGraph.DrawLine(Pens.Black, rectContent.Left, rectContent.Bottom, rectContent.Left + rectContent.Width, rectContent.Bottom);
                    myGraph.DrawString("第  " + (count + doc.PageStartIndex) + "  页", bottomPageCurrent, Brushes.Black, new Rectangle(rectContent.Left, rectContent.Bottom + 5, rectContent.Width, 20), doc.titleStringFormat);
                }
            }
            if (DrawMargin)
            {
                int num = 20;
                int rectContentLeft = rectContent.Left;
                int rectContentRight = rectContent.Right;
                int rectContentBottom = rectContent.Bottom;
                int rectcontentTop = rectContent.Top;
                using (Pen pen = new Pen(Color.Gray))
                {
                    myGraph.DrawLine(pen, rectContentLeft, rectcontentTop, rectContentLeft - num, rectcontentTop);
                    myGraph.DrawLine(pen, rectContentLeft, rectcontentTop, rectContentLeft, rectcontentTop - num);
                    myGraph.DrawLine(pen, rectContentRight, rectcontentTop, rectContentRight + num, rectcontentTop);
                    myGraph.DrawLine(pen, rectContentRight, rectcontentTop, rectContentRight, rectcontentTop - num);
                    myGraph.DrawLine(pen, rectContentRight, rectContentBottom, rectContentRight + num, rectContentBottom);
                    myGraph.DrawLine(pen, rectContentRight, rectContentBottom, rectContentRight, rectContentBottom + num);
                    myGraph.DrawLine(pen, rectContentLeft, rectContentBottom, rectContentLeft, rectContentBottom + num);
                    myGraph.DrawLine(pen, rectContentLeft, rectContentBottom, rectContentLeft - num, rectContentBottom);
                }
            }
        }

        public static int GetTextWidth(Graphics g, string name, Font f)
        {
            return (int)g.MeasureString(name, f, 1000, StringFormat.GenericTypographic).Width;
        }

        public void Watermark(int x, int y, Graphics g)
        {
            Color color = Color.FromArgb(50, Color.Gray);
            Font font = new Font("Verdana", 32);
            Brush brush = new SolidBrush(color);
            for (int i = 0; i < 10; i++)
            {
                g.DrawString("草 稿", font, brush, x + i * 75, y + i * 120);
            }
        }

        public void DrawPageFrame(int x, int y, Graphics myGraph, bool DrawMargin, Color BackColor)
        {
            Rectangle rect = new Rectangle(x, y, this.intPaperWidth, this.intPaperHeight);
            using (SolidBrush brush = new SolidBrush(BackColor))
            {
                myGraph.FillRectangle(brush, rect);
            }

            myGraph.DrawRectangle(Pens.Black, rect);//纸张边框颜色
            //***************如果显示页面的四个角 绘制************************
            if (DrawMargin)
            {
                int num2 = this.intLeftMargin;
                rect = new Rectangle(x + this.intLeftMargin, y + this.intTopMargin, this.StandardWidth, this.StandardHeight);
                int num = 20;
                Pen p = new Pen(Color.Gray);//添加灰色画笔，绘制灰色的四个角
                myGraph.DrawLine(p, rect.Left, rect.Top, rect.Left - num, rect.Top);
                myGraph.DrawLine(p, rect.Left, rect.Top, rect.Left, rect.Top - num);
                myGraph.DrawLine(p, rect.Right, rect.Top, rect.Right + num, rect.Top);
                myGraph.DrawLine(p, rect.Right, rect.Top, rect.Right, rect.Top - num);
                myGraph.DrawLine(p, rect.Right, rect.Bottom, rect.Right + num, rect.Bottom);
                myGraph.DrawLine(p, rect.Right, rect.Bottom, rect.Right, rect.Bottom + num);
                myGraph.DrawLine(p, rect.Left, rect.Bottom, rect.Left, rect.Bottom + num);
                myGraph.DrawLine(p, rect.Left, rect.Bottom, rect.Left - num, rect.Bottom);
            }
            //string strHeadString = "<a><text fontname='仿宋_GB2312' fontsize='12' bold='bold' center='center'>XXX医院</text><text fontname='仿宋_GB2312' fontsize='18' bold='bold' center='center'>入 院 记 录</text><text fontname='仿宋_GB2312' fontsize='12' center='center'>姓名：张三    住院号：009988    床号：10床    科室：神经内一科</text><line thick='1'></line></a>";
            // transString(new Rectangle(rect.Left, rect.Top - 93, 600, 200), myGraph, strHeadString);
        }

        public int GetPageMaxWidth()
        {
            int width = 0;
            foreach (PrintPage page in this.myItems)
            {
                if (page.Width > width)
                {
                    width = page.Width;
                }
            }
            return ((width + this.intLeftMargin) + this.intRightMargin);
        }

        public int IndexOf(PrintPage myPage)
        {
            return this.myItems.IndexOf(myPage);
        }

        public PrintPage NewPage()
        {
            PrintPage page = new PrintPage();
            page.OwnerPages = this;
            page.Height = this.StandardHeight;
            page.Width = this.StandardWidth;
            return page;
        }

        public void RemovePage(PrintPage myPage)
        {
            if (this.myItems.Contains(myPage))
            {
                this.myItems.Remove(myPage);
            }
        }

        public bool SetPageMargins(int iTopMargin, int iBottomMargin, int iLeftMargin, int iRightMargin)
        {
            this.PageSettings.Margins.Left = iLeftMargin;
            this.PageSettings.Margins.Right = iRightMargin;
            this.PageSettings.Margins.Top = iTopMargin;
            this.PageSettings.Margins.Bottom = iBottomMargin;
            this.UpdatePageSettings();
            return true;
        }

        public bool SetPageMargins(float fTopMargin, float fBottomMargin, float fLeftMargin, float fRightMargin)
        {
            float num = fLeftMargin * 37.8f;
            num += 0.5f;
            this.PageSettings.Margins.Left = (int)num;
            num = fRightMargin * 37.8f;
            num += 0.5f;
            this.PageSettings.Margins.Right = (int)num;
            num = fTopMargin * 37.8f;
            num += 0.5f;
            this.PageSettings.Margins.Top = (int)num;
            num = fBottomMargin * 37.8f;
            num += 0.5f;
            this.PageSettings.Margins.Bottom = (int)num;
            this.UpdatePageSettings();
            return true;
        }

        public bool SetPageSize(int iWidth, int iHeight)
        {
            if (!this.CustomPageSize)
            {
                this.PageSettings.PaperSize = new PaperSize("Custom", iWidth, iHeight);
            }
            else
            {
                this.PageSettings.PaperSize.Width = iWidth;
                this.PageSettings.PaperSize.Height = iHeight;
            }
            this.UpdatePageSettings();
            return true;
        }

        public bool SetPageSize(float fWidth, float fHeight)
        {
            float num = fWidth * 37.8f;
            num += 0.5f;
            int width = (int)num;
            num = fHeight * 37.8f;
            num += 0.5f;
            int height = (int)num;
            if (!this.CustomPageSize)
            {
                this.PageSettings.PaperSize = new PaperSize("Custom", width, height);
            }
            else
            {
                this.PageSettings.PaperSize.Width = width;
                this.PageSettings.PaperSize.Height = height;
            }
            this.UpdatePageSettings();
            return true;
        }

        public void UpdatePageSettings()
        {
            //double yincun = 2.54;
            //this.intPaperWidth = (int)(21 / yincun * 96);//784;  //(int)(this.myPageSettings.PaperSize.Width * num);
            //this.intPaperHeight = (int)(29.7 / yincun * 96);// 1045;//s (int)(this.myPageSettings.PaperSize.Height * num);
            //this.intLeftMargin = (int)(2.5 / yincun * 96);//50;   //(int)(this.myPageSettings.Margins.Left * num);
            //this.intTopMargin = (int)(5 / yincun * 96);//130;   //(int)(this.myPageSettings.Margins.Top * num);
            //this.intRightMargin = (int)(1 / yincun * 96);// 50;  //(int)(this.myPageSettings.Margins.Right * num);
            //this.intBottomMargin = (int)(2.5 / yincun * 96);// 60; //(int)(this.myPageSettings.Margins.Bottom * num);        
            //this.titleMarginTop = (int)(2.5 / yincun * 96);
        }

        public static void transString(Rectangle rec, Graphics g, string text)
        {
            Font DefaultFont = Control.DefaultFont;
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(text);
            int TopCount = rec.Top;
            using (StringFormat format = new StringFormat())
            {
                format.Alignment = StringAlignment.Near;
                format.LineAlignment = StringAlignment.Center;
                format.FormatFlags = StringFormatFlags.NoWrap;
                foreach (XmlNode node in doc.DocumentElement.ChildNodes)
                {
                    if (!(node is XmlElement))
                    {
                        continue;
                    }
                    XmlElement element = (XmlElement)node;
                    if (element.Name == "line")
                    {
                        using (Pen pen = new Pen(Color.Black))
                        {
                            if (element.HasAttribute("thick"))
                            {
                                pen.Width = Convert.ToInt32(element.GetAttribute("thick"));
                            }
                            g.DrawLine(pen, rec.Left, TopCount, rec.Right, TopCount);
                            TopCount = (TopCount + ((int)pen.Width)) + 20;
                        }
                        continue;
                    }
                    if (element.Name == "text")
                    {
                        string FontName = DefaultFont.Name;
                        if (element.HasAttribute("fontname"))
                        {
                            FontName = element.GetAttribute("fontname");
                        }
                        int FontSize = (int)DefaultFont.Size;
                        if (element.HasAttribute("fontsize"))
                        {
                            FontSize = Convert.ToInt32(element.GetAttribute("fontsize"));
                        }
                        FontStyle style = FontStyle.Regular;
                        if (element.HasAttribute("bold"))
                        {
                            style |= FontStyle.Bold;
                        }
                        if (element.HasAttribute("italic"))
                        {
                            style |= FontStyle.Italic;
                        }
                        if (element.HasAttribute("underline"))
                        {
                            style |= FontStyle.Underline;
                        }
                        format.Alignment = StringAlignment.Near;
                        if (element.HasAttribute("left"))
                        {
                            format.Alignment = StringAlignment.Near;
                        }
                        if (element.HasAttribute("center"))
                        {
                            format.Alignment = StringAlignment.Center;
                        }
                        if (element.HasAttribute("right"))
                        {
                            format.Alignment = StringAlignment.Far;
                        }
                        using (Font font = new Font(FontName, (float)FontSize, style))
                        {
                            float h = g.MeasureString("#", font, 0x2710, format).Height + 10f;
                            RectangleF rect = new RectangleF((float)rec.Left, (float)TopCount, (float)rec.Width, h);
                            if (rect.Bottom > rec.Bottom)
                            {
                                return;
                            }
                            string txt2 = element.InnerText;
                            if ((txt2 != null) && (txt2.Length > 0))
                            {
                                g.DrawString(txt2, font, Brushes.Black, rect, format);
                            }
                            TopCount += (int)Math.Ceiling((double)h);
                            continue;
                        }
                    }
                }
            }
        }

        public int BodyHeight
        {
            get
            {
                int num = 0;
                foreach (PrintPage page in this.myItems)
                {
                    num += (page.Height - this.intHeadHeight) - this.intTailHeight;
                }
                return num;
            }
        }

        public int Count
        {
            get
            {
                return this.myItems.Count;
            }
        }

        public bool CustomPageSize
        {
            get
            {
                return (this.PageSettings.PaperSize.Kind == PaperKind.Custom);
            }
        }

        public PrintPage FirstPage
        {
            get
            {
                if (this.myItems.Count > 0)
                {
                    return (PrintPage)this.myItems[0];
                }
                return null;
            }
        }

        public int HeadHeight
        {
            get
            {
                return this.intHeadHeight;
            }
            set
            {
                this.intHeadHeight = value;
            }
        }

        public int Height
        {
            get
            {
                int num = 0;
                foreach (PrintPage page in this.myItems)
                {
                    num += page.Height;
                }
                return num;
            }
        }

        public PrintPage this[int index]
        {
            get
            {
                if ((index >= 0) && (index < this.myItems.Count))
                {
                    return (PrintPage)this.myItems[index];
                }
                return null;
            }
        }

        public ArrayList Items
        {
            get
            {
                return this.myItems;
            }
        }

        public PrintPage LastPage
        {
            get
            {
                if (this.myItems.Count > 0)
                {
                    return (PrintPage)this.myItems[this.myItems.Count - 1];
                }
                return null;
            }
        }

        public int MinPageHeight
        {
            get
            {
                return this.intMinPageHeight;
            }
            set
            {
                this.intMinPageHeight = value;
            }
        }

        public System.Drawing.Printing.PageSettings PageSettings
        {
            get
            {
                return this.myPageSettings;
            }
            set
            {
                this.myPageSettings = value;
                this.UpdatePageSettings();
            }
        }

        public int StandardHeight
        {
            get
            {
                return ((((this.intPaperHeight - this.intTopMargin) - this.intBottomMargin) - this.intHeadHeight) - this.intTailHeight);
            }
        }

        public int StandardWidth
        {
            get
            {
                return ((this.intPaperWidth - this.intLeftMargin) - this.intRightMargin);
            }
        }

        public int TailHeight
        {
            get
            {
                return this.intTailHeight;
            }
            set
            {
                this.intTailHeight = value;
            }
        }

        public int Top
        {
            get
            {
                return this.intTop;
            }
            set
            {
                this.intTop = value;
            }
        }

        public int FooterHeight
        {
            get
            {
                return this.intFooterHeight;
            }
            set
            {
                this.intFooterHeight = value;
            }
        }
        public int DocumentHeight
        {
            get
            {
                return this.intDocumentHeight;
            }
            set
            {
                this.intDocumentHeight = value;
            }
        }
    }

    public class PageHeaderNode
    {
        public string HeaderStr = string.Empty;
        public int Width = 0;
        public PageHeaderNode(string str, int width)
        {
            this.HeaderStr = str;
            this.Width = width;
        }
    }
}

